<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:75:"/opt/lampp/htdocs/zfshlm_5_0/public/../application/front/view/v2/test1.html";i:1528942557;}*/ ?>
<!DOCTYPE html>
<html>
<meta name="format-detection"  content="telephone=no">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<meta  http-equiv="x-rim-auto-match" content="none">
<meta charset="UTF-8">
<meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0;" name="viewport;">
<meta content="user-scalable=no" name="viewport">
 <head>
        <meta name="Generator" content="EditPlus®" />
        <meta name="Author" content="" />
        <meta name="Keywords" content="" />
        <meta name="Description" content="" />
        <title>Document</title>
        <script src="http://__JS__//jquery.js"></script>
          <script src="http://__JS__//jquery.cookie.js"></script>
    </head>
    <body>
 <input id="phonenum" type="text" value="18321011111" />
        <input id="second" type="button" value="免费获取验证码" />
    </body>
    <script type="text/javascript">
        //发送验证码时添加cookie
        function addCookie(name, value, expiresHours) {
            //判断是否设置过期时间,0代表关闭浏览器时失效
            if (expiresHours > 0) {
                var date = new Date();
                date.setTime(date.getTime() + expiresHours * 1000);
                $.cookie(name, escape(value), { expires: date });
            } else {
                $.cookie(name, escape(value));
            }
        }

        //修改cookie的值
        function editCookie(name, value, expiresHours) {
            if (expiresHours > 0) {
                var date = new Date();
                date.setTime(date.getTime() + expiresHours * 1000); //单位是毫秒
                $.cookie(name, escape(value), { expires: date });
            } else {
                $.cookie(name, escape(value));
            }
        }

        //根据名字获取cookie的值
        function getCookieValue(name) {
            return $.cookie(name);
        }

        $(function() {
            $("#second").click(function() {
                sendCode($("#second"));
            });
            v = getCookieValue("secondsremained"); //获取cookie值
            if (v > 0) {
                settime($("#second")); //开始倒计时
            }
        });


        //发送验证码
        function sendCode(obj) {
            var phonenum = $("#phonenum").val();
            var result = isPhoneNum();
            if (result) {
                // doPostBack('${base}/login/getCode.htm',backFunc1,{"phonenum":phonenum});
                addCookie("secondsremained", 60, 60); //添加cookie记录,有效时间60s
                settime(obj); //开始倒计时
            }
        }

        //开始倒计时
        var countdown;

        function settime(obj) {
            countdown = getCookieValue("secondsremained");
            //alert(countdown);
            if (countdown == 0 || countdown == undefined) {
                obj.removeAttr("disabled");
                obj.val("提现");
                return;
            } else {
                obj.attr("disabled", true);
                obj.val("等待提现(" + countdown + ")");
                countdown--;
                editCookie("secondsremained", countdown, countdown + 1);
            }
            setTimeout(function() { settime(obj); }, 1000); //每1000毫秒执行一次
        }

        //校验手机号是否合法
        function isPhoneNum() {
            var phonenum = $("#phonenum").val();
            var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
            if (!myreg.test(phonenum)) {
                alert('请输入有效的手机号码！');
                return false;
            } else {
                return true;
            }
        }
    </script>
</html>